package com.yunhe.rentcars.pro.service.client.impl;

import com.yunhe.rentcars.commons.annoaction.Log;
import com.yunhe.rentcars.commons.dto.Pageable;
import com.yunhe.rentcars.pro.dao.client.BlackListDao;
import com.yunhe.rentcars.pro.entity.client.BacList;
import com.yunhe.rentcars.pro.service.client.BlackListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2017/11/24 0024.
 */
@Service
public class BlackListServiceImpl implements BlackListService {
    @Autowired
    private BlackListDao blackListDao;
    @Override
    public Pageable<BacList> findPage(Integer offset, Integer limit) {
        List<BacList> list = blackListDao.findPage(offset, limit);
        int count = blackListDao.count();
        Pageable<BacList> pageable=new Pageable<>();
        pageable.setRows(list);
        pageable.setTotal(count);
        return pageable;
    }

    @Override
    @Log(value = "添加黑名单",type = 1)
    public void save(BacList bacList) {
        blackListDao.save(bacList);
    }

    @Override
    @Log(value = "删除黑名单",type = 1)
    public void delBatch(String[] ids) {
        blackListDao.delBatch(ids);
    }


    @Override
    public BacList find(Long bId) {
        BacList bacList = blackListDao.find(bId);
        return bacList;
    }

    @Override
    @Log(value = "修改黑名单",type = 1)
    public void update(BacList bacList) {
        blackListDao.update(bacList);
    }

    @Override
    public Pageable<BacList> findSearchList(String mobile, String name, String idCard) {
        List<BacList> searchList = blackListDao.findSearchList(mobile, name, idCard);
        int count = blackListDao.count();
        Pageable<BacList> pageable=new Pageable();
        pageable.setTotal(count);
        pageable.setRows(searchList);
        return pageable;
    }
}
